package cn.sdormitory.smartclass.dao;

import cn.sdormitory.smartclass.entity.ClassAttence;
import cn.sdormitory.smartclass.form.StudentClassAttendanceQueryForm;
import cn.sdormitory.smartclass.vo.ClassAttenceVo;
import cn.sdormitory.smartclass.vo.StudentClassAttendanceVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @创建人：zhouyang
 * @创建时间：2021/12/20 16:00
 * @version：V1.0
 */
@Mapper
public interface ClassAttenceDao extends BaseMapper<ClassAttence> {
    int getAppClaStuAttCount(@Param("classId")Long classId,@Param("accessDate")String accessDate,@Param("timeSlot")String timeSlot);
    List<ClassAttenceVo> getAppClaStuAttByClaIdAndSlot(@Param("classId")Long classId,@Param("accessDate")String accessDate,@Param("timeSlot")String timeSlot);
    List<ClassAttenceVo> getAppClaStuByClaId(@Param("classId")Long classId);
    int getClaAttByDateAndStuNo(@Param("studentNo") String studentNo,@Param("accessDate") String accessDate,@Param("timeSlot") String timeSlot);
    int updateClaAttStatus(@Param("studentNo") String studentNo,@Param("accessDate") String accessDate,@Param("attenceStatus") String attenceStatus,@Param("timeSlot") String timeSlot);
    List<ClassAttenceVo> getAppClaStayStuByClaId(@Param("classId")Long classId);

//    @Select("SELECT * FROM class_attence WHERE student_no = #{studentNo} AND attence_status != '1'")
    List<ClassAttenceVo> findClassAttendanceByStuNo(@Param("studentNo")String studentNo);

    /**
     *
     * @param classId 班级id
     * @param accessDate 考勤日期
     * @param attenceStatus 考勤状态
     * @param timeSlot 考勤时间段
     * @return
     */
    int getClsAttenceCountByCondition(@Param("classId") Long classId,
                                      @Param("accessDate")String accessDate,
                                      @Param("attenceStatus")String attenceStatus,
                                      @Param("timeSlot")String timeSlot);

    List<String> getClassAttenceStuByCondition(@Param("condition")ClassAttence condition);

    /**
     * 查询未打卡学生列表
     * @param condition
     * @return
     */
    List<String> getUnClockInStudent(@Param("condition")ClassAttence condition);

    IPage<StudentClassAttendanceVo> getStudentClassAttendancePage(Page<ClassAttence> page, StudentClassAttendanceQueryForm form);
}
